package com.yuexunit.operationman.nbsy.module.SurgicalReceipt.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.yuexunit.operationman.nbsy.R;
import com.yuexunit.operationman.nbsy.config.AppConfig;
import com.yuexunit.operationman.nbsy.module.SurgicalReceipt.Bean.SurgicalReceiptBean;
import com.yuexunit.operationman.nbsy.module.SurgicalReceipt.ui.Act_SurgicalReceipt_Preview;

import org.kymjs.kjframe.ui.KJFragment;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by chenss on 2017/7/27 0027.
 */

public class Fragment_SR_Postoperative extends KJFragment {

    @Bind(R.id.frag_sr_po01)
    TextView fragSrPo01;
    @Bind(R.id.frag_sr_po02)
    TextView fragSrPo02;
    @Bind(R.id.frag_sr_po03)
    TextView fragSrPo03;
    @Bind(R.id.frag_sr_po04)
    TextView fragSrPo04;
    @Bind(R.id.frag_sr_po05)
    TextView fragSrPo05;
    @Bind(R.id.frag_sr_po06)
    TextView fragSrPo06;
    @Bind(R.id.frag_sr_po07)
    TextView fragSrPo07;
    @Bind(R.id.textView4)
    TextView textView4;
    @Bind(R.id.frag_sr_po08)
    TextView fragSrPo08;
    @Bind(R.id.frag_sr_po09)
    TextView fragSrPo09;
    @Bind(R.id.frag_sr_po10)
    TextView fragSrPo10;
    @Bind(R.id.frag_sr_po11)
    TextView fragSrPo11;
    @Bind(R.id.frag_sr_po12)
    TextView fragSrPo12;
    @Bind(R.id.frag_sr_po13)
    TextView fragSrPo13;
    @Bind(R.id.frag_sr_po14)
    TextView fragSrPo14;
    private Act_SurgicalReceipt_Preview aty;
    protected View mMainView;

    @Override
    protected View inflaterView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
        aty = (Act_SurgicalReceipt_Preview) getActivity();
        mMainView = inflater.inflate(R.layout.fragment_sr_postoperative, container, false);
        ButterKnife.bind(this, mMainView);
        return mMainView;
    }

    protected void initData() {
        for (SurgicalReceiptBean.ObjectEntity.HandoverItemListEntity p : AppConfig.SURGICALRECEIPTBEAN.getObject().getHandoverItemList()) {
            switch (p.getItemCode()) {
                case "FB_ShenFenQueRen":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        if (skin[0].equals("1")) {
                            fragSrPo01.setText("是");
                        }
                        else {
                            fragSrPo01.setText("否");
                        }
                    }
                    break;
                case "FB_YiShi":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        String[] arrays = getResources().getStringArray(R.array.surgicalreceipt_fb_01);
                        if (skin[0].equals("1")) {
                            fragSrPo02.setText(arrays[0]);
                        }
                        if (skin[1].equals("1")) {
                            fragSrPo02.setText(arrays[1]);
                        }
                        if (skin[2].equals("1")) {
                            fragSrPo02.setText(arrays[2]);
                        }
                        if (skin[3].equals("1")) {
                            fragSrPo02.setText(arrays[3]);
                        }
                        if (skin[4].equals("1")) {
                            fragSrPo02.setText(arrays[4]);
                        }
                    }
                    break;
                case "FB_ShenMingTiZheng":
                    if(p.getItemValue().length() > 0)
                    {
                        String[] skin = p.getItemValue().split(";", -1);
                        String content = "";
                        String[] arrays = getResources().getStringArray(R.array.surgicalreceipt_fb_02);
                        if(skin[0].equals("1"))
                        {
                            content+=arrays[0];
                        }
                        fragSrPo03.setText(content);
                    }
                    break;
                case "FB_YaChuang":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        if (skin[0].equals("1")) {
                            fragSrPo04.setText("无");
                        }
                        if (skin[1].equals("1")) {
                            fragSrPo04.setText("有"+"\n"+skin[2]+"\n"+skin[3]);
                        }
                    }
                    break;
                case "FB_XueZhiPin":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        if (skin[0].equals("1")) {
                            fragSrPo05.setText("无");
                        }
                        if (skin[1].equals("1")) {
                            fragSrPo05.setText("有");
                        }
                    }
                    break;
                case "FB_Guandao":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        String content = "";
                        String[] arrays = getResources().getStringArray(R.array.surgicalreceipt_bs_04);
                        if (skin[0].equals("1")) {
                            content+="无";
                        }
                        if (skin[1].equals("1")) {
                            content+="有";
                            if (skin[2].equals("1")) {
                                content += "\n";
                                content +=arrays[0]+"长度"+skin[11]+"cm";
                            }
                            if (skin[3].equals("1")) {
                                content += "\n";
                                content +=arrays[1];
                            }
                            if (skin[4].equals("1")) {
                                content += "\n";
                                content +=arrays[2];
                            }
                            if (skin[5].equals("1")) {
                                content += "\n";
                                content +=arrays[3];
                            }
                            if (skin[6].equals("1")) {
                                content += "\n";
                                content +=arrays[4];
                            }
                            if (skin[7].equals("1")) {
                                content += "\n";
                                content +=arrays[5]+"数量"+skin[12]+"根";
                            }
                            if (skin[8].equals("1")) {
                                content += "\n";
                                content +=arrays[6];
                            }
                            if (skin[9].equals("1")) {
                                content += "\n";
                                content +=arrays[7];
                            }
                            if (skin[10].equals("1")) {
                                content += "\n";
                                content +=arrays[8];
                            }
                        }

                        if(p.getItemOther().length() > 0)
                        {
                            content += "\n";
                            content +="其他:"+p.getItemOther();
                        }
                        fragSrPo06.setText(content);
                    }
                    break;
                case "FB_ZhiTongBeng":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        if (skin[0].equals("1")) {
                            fragSrPo07.setText("无");
                        }
                        if (skin[1].equals("1")) {
                            fragSrPo07.setText("有");
                        }
                    }
                    break;
                case "FB_ZiLiao":
                    if (p.getItemValue().length() > 0) {
                        fragSrPo08.setText(p.getItemValue());
                    }
                    break;
                case "FB_XiYangFangShi":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        String[] arrays = getResources().getStringArray(R.array.surgicalreceipt_fb_03);
                        if (skin[0].equals("1")) {
                            fragSrPo09.setText(arrays[0]);
                        }
                        if (skin[1].equals("1")) {
                            fragSrPo09.setText(arrays[1]);
                        }
                        if (skin[2].equals("1")) {
                            fragSrPo09.setText(arrays[2]);
                        }
                        if (skin[3].equals("1")) {
                            fragSrPo09.setText(arrays[3]);
                        }
                        if (skin[4].equals("1")) {
                            fragSrPo09.setText(arrays[4]);
                        }
                        if (skin[5].equals("1")) {
                            fragSrPo09.setText(arrays[5]);
                        }
                        if (skin[6].equals("1")) {
                            fragSrPo09.setText(arrays[6]);
                        }
                    }
                    break;
                case "FB_Other":
                    if (p.getItemOther().length() > 0) {
                        fragSrPo10.setText(p.getItemOther());
                    }
                    break;
            }
        }
        if(AppConfig.SURGICALRECEIPTBEAN.getObject().getTransferHandover().getFbRrNurseUrl() != null){
            fragSrPo11.setText(AppConfig.SURGICALRECEIPTBEAN.getObject().getTransferHandover().getFbRrNurse());
            fragSrPo12.setText(AppConfig.SURGICALRECEIPTBEAN.getObject().getTransferHandover().getFbRrNurseTimeStr());
        }
        if(AppConfig.SURGICALRECEIPTBEAN.getObject().getTransferHandover().getFbWardNurseUrl() != null){
            fragSrPo13.setText(AppConfig.SURGICALRECEIPTBEAN.getObject().getTransferHandover().getFbWardNurse());
            fragSrPo14.setText(AppConfig.SURGICALRECEIPTBEAN.getObject().getTransferHandover().getFbWardNurseTimeStr());
        }
    }
}
